package cn.doitedu.day01.demo

import scala.io.Source

/**
 * @Date 22.3.28
 * @Created by HANGGE
 * @Description
 */
object C02_Compute {
  def main(args: Array[String]): Unit = {

    val source = Source.fromFile("data/word.txt")
    val lines: Iterator[String] = source.getLines()

    val rdd1: Iterator[String] = lines.map(line => {
      println("第一步计算")
      line.toUpperCase
    })

    val rdd2: Iterator[String] = rdd1.flatMap(line=>{
      println("第二步计算")
      line.split("\\s+")
    })

   val rdd3: Iterator[(String, Int)] = rdd2.map(word=>{
      println("第三步计算")
      (word,1)
    })
   //说明三步计算都没有进行

   val myRDD =  lines.map(line => {
      println("第一步计算")
      line.toUpperCase
    }).flatMap(line=>{
      println("第二步计算")
      line.split("\\s+")
    }).map(word=>{
      println("第三步计算")
      (word,1)
    })


    println(rdd3)

   rdd2.foreach(println)




  }

}
